<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:wh="http://java.sun.com/jsf/composite/wh"
	xmlns:p="http://primefaces.org/ui">
<h:body>
	<ui:composition template="template/companyTemplate.xhtml">
		<ui:define name="companyContent">

			<h1>Products</h1>
			<h:form id="companyProductOverview" styleClass="horizontal_full">

				<p>
					Here you can choose different products of different suppliers which
					you want to sell. You can have a look on the details or just add it
					to your
					<p:link value="product sortiment"
						outcome="companySelectedProductsForSale?faces-redirect=true" />
					where you can remove it again. But be careful, do not choose to much products. 
					If you have too much products in your product sortiment you have to pay additional 
					logistic costs. Theses logistic costs can also be seen on the Chosen Products page 
					at the bottom of the table (Additional Portfolio Costs).
				</p>

				<p:dataTable id="productTable" var="product"
					value="#{companyMBean.products}" selectionMode="single"
					rowKey="#{product.id}"
					paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {Exporters}"
					rowsPerPageTemplate="10,25,50,100" paginator="true" rows="10"
					resizableColumns="true">
					<f:facet name="header">
					            Products Overview
					        </f:facet>

					<f:facet name="{Exporters}">
						<h:commandLink>
							<p:graphicImage library="img" name="excel.png" width="24" />
							<p:dataExporter type="xls" target="productTable"
								fileName="productTable" />
						</h:commandLink>
						<h:commandLink>
							<p:graphicImage library="img" name="pdf.png" width="24" />
							<p:dataExporter type="pdf" target="productTable"
								fileName="productTable" />
						</h:commandLink>
					</f:facet>

					<p:column headerText="Name" sortBy="#{product.name}" width="32%">
						<h:outputText value="#{product.name}" />
					</p:column>

					<p:column headerText="Costs" sortBy="#{product.productCosts}" width="12%">
						<h:outputText value="#{product.productCosts}" />
					</p:column>
					
					<!--  
					<p:column headerText="Quality" sortBy="#{product.qualityFactor}">
						<h:outputText value="#{product.qualityFactor}" />
					</p:column>
					-->
					<p:column headerText="Quality" sortBy="#{product.qualityFactor}" width="16%">
						<p:rating id="qualityRating" value="#{product.getQualityFactorStars()}" stars="5" readonly="true" />
					</p:column>
					
					<p:column headerText="Supplier"
						sortBy="#{product.supplier.supplierName}" width="16%">
						<h:outputText value="#{product.supplier.supplierName}" />
					</p:column>

					<p:column headerText="Product details" exportable="false" width="12%">
						<p:commandButton icon="ui-icon-search" title="View"
							action="#{companyMBean.actionShowProductDetail()}">
							<f:setPropertyActionListener value="#{product}"
								target="#{companyMBean.selectedProduct}" />
						</p:commandButton>
					</p:column>
					
					<!-- 
					<p:column headerText="Choose product" exportable="false" width="12%">
						<p:commandButton icon="ui-icon-cart" title="Add to sortiment"
							action="#{companyMBean.actionAddCompanyProduct}">
							<f:setPropertyActionListener value="#{product}"
								target="#{companyMBean.selectedProduct}" />
						</p:commandButton>
					</p:column>
					 -->
					<p:column headerText="Choose product" exportable="false" width="12%">
						<p:commandButton icon="ui-icon-cart" actionListener="#{companyMBean.setSellingPrice(product.id)}">
								<p:ajax event="dialogReturn" listener="#{companyMBean.onSellingPriceSet}" />
						</p:commandButton>
					</p:column>

				</p:dataTable>

			</h:form>

		</ui:define>
	</ui:composition>
</h:body>
</html>